#include "detectionwindowinfo.h"

DetectionWindowInfo::DetectionWindowInfo() {}


bool DetectionWindowInfo::writeXML(const QXmlStreamWriter &writer){
    return true;
}

bool DetectionWindowInfo::ReadXML(QXmlStreamReader &reader){
    QString className = reader.name().toString();

    while (!(reader.tokenType() == QXmlStreamReader::EndElement &&
             reader.name() == QStringLiteral("detectionWindowInfo"))) {

        className = reader.name().toString();

        if (reader.name() == QStringLiteral("column")) {
            m_nColumn = reader.readElementText().toInt();
        }else if (reader.name() == QStringLiteral("row")) {
            m_nRow = reader.readElementText().toInt();
        }else if (reader.name() == QStringLiteral("total")) {
            m_nTotal = reader.readElementText().toInt();
        }

        reader.readNext();
    }

    reader.readNext();
    reader.readNext();
    return true;
}

int         m_nColumn;
int         m_nRow;
int         m_nTotal;

QJsonObject DetectionWindowInfo::toJson(){
    QJsonObject obj;
    obj["Column"] = this->m_nColumn;
    obj["Row"] = this->m_nRow;
    obj["Total"] = this->m_nTotal;
    return obj;
}

void DetectionWindowInfo::fromJson(QJsonObject obj){
    this->m_nColumn = obj["Column"].toInt();
    this->m_nRow = obj["Row"].toInt();
    this->m_nTotal = obj["Total"].toInt();
}
